﻿using System.ComponentModel.Composition;
using System.Windows;
using MediaAssistant.Data;
using MediaAssistant.Management;
using MefBasic;
using MefBasic.Commans;
using MediaAssistant.DAL;
using MediaAssistant.DAL.Constants;

namespace MediaAssistant.Controls.MovieList
{
    [Export]
    public class MovieListPresenter:APresenter<MovieListView>
    {
        [ImportingConstructor]
        public MovieListPresenter(MovieListView view) : base(view)
        {
            SelectedMovieChangedCommand = new DelegateCommand(ExecuteSelectedMovieChanged);
        }
        
        private void ExecuteSelectedMovieChanged(object obj)
        {
            DataSource.SelectedMovie = (Movie)obj;
        }

        public DelegateCommand SelectedMovieChangedCommand { get; set; }

        [Import]
        public LibraryDataSource DataSource
        {
            get { return (LibraryDataSource)GetValue(DataSourceProperty); }
            set { SetValue(DataSourceProperty, value); }
        }

        public static readonly DependencyProperty DataSourceProperty =
            DependencyProperty.Register("DataSource", typeof(LibraryDataSource), typeof(MovieListPresenter), new UIPropertyMetadata(null));

        [Import]
        public WaitScreenService WaitScreenService { get; set; }
    }
}
